<?php
header("Content-type:application/vnd.ms-excel");
header("Content-Disposition:filename=table.xls");
include_once "../function.php";
if($_GET['table']=='bonus'){//奖金总表
	$str="会员编号\t会员姓名\t层碰\t领导奖\t补贴\t点费\t代奖\t店补\t重复消费\t实际发放\t\n";
	echo $str;
	$sql="select * from member m left join bonus b on m.id=b.uid where did={$_GET['time']} order by bdate asc";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['b1']."\t";
		echo $row['b2']."\t";
		echo $row['b3']."\t";
		echo $row['b4']."\t";
		echo $row['b5']."\t";
		echo $row['b6']."\t";
		echo $row['b7']."\t";
		echo $row['b0']."\t\n";
	}
}elseif($_GET['table']=='tixian'){//提现表
	$str="会员编号\t会员姓名\t提现金额\t手续费\t实发金额\t开户银行\t开户姓名\t开户帐号\t开户地址\t提现时间\t服务中心\t审核状态\t\n";
	echo $str;
	$sql="select * from tixian";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['jine']."\t";
		echo $row['shouxu']."\t";
		echo number_format($row['jine']-$row['shouxu'],2)."\t";
		echo $row['bankname']."\t";
		echo $row['bankusername']."\t";
        echo "'".$row['bankcard']."'"."\t";
		echo $row['bankaddress']."\t";
		echo $row['tdate']."\t";
		echo $row['bdname']."\t";
		if ($row['isgrant']==1){
			echo $row['bankaddress']."已发放\t\n";
		}else{ 
			echo "未发放\t\n";
		}
		
	}
}elseif($_GET['table']=='chongzhi'){//充值表
	$str="会员编号\t会员姓名\t申请金额\t充值时间\t申请类型\t审核状态t\n";
	echo $str;
	$sql="select * from chongzhi";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['jine']."\t";
		echo $row['cdate']."\t";
		if($row['lx']==0){
			echo "报单币\t";
		}elseif($row['lx']==1){
			echo "奖金币\t";
		}elseif($row['lx']==2){
            echo "电子币\t";
        }
		if ($row['isgrant']==1){
			echo "已发放\t\n";
		}else{
			echo "未发放\t\n";
		}
	
	}
}elseif($_GET['table']=='huikuan'){//汇款
$str="会员编号\t会员姓名\t汇款银行\t账户姓名\t汇款账户\t汇款金额\t汇款时间\t汇款说明\t记录时间\t服务中心\t汇款确认\t\n";
	echo $str;
	$sql="select * from huikuan";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['bankname']."\t";
		echo $row['bankusername']."\t";
		echo $row['bankcard']."\t";
		echo $row['jine']."\t";
		echo $row['sdate']."\t";
		echo $row['shuoming']."\t";
		echo $row['hdate']."\t";
		echo $row['snickname']."\t";
		if ($row['isgrant']==1){
			echo $row['bankaddress']."已确认\t\n";
		}else{ 
			echo "未确认\t\n";
		}
		
	}
}elseif($_GET['table']=='zhuanzhang'){
	$str="转出会员编号\t转出会员姓名\t转入会员编号\t转入会员姓名\t转账金额\t转账类型\t转账时间t\n";
	echo $str;
	$sql="select * from zhuanzhang";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['snickname']."\t";
		echo $row['susername']."\t";
		echo $row['jine']."\t";
		if($row['lx']==0){
			echo "电子币\t";
		}elseif($row['lx']==1){
			echo "购物币\t";
		}elseif($row['lx']==2){
			echo "奖金\t";
		}
		echo $row['zdate']."\t\n";
	}
}elseif($_GET['table']=='zhuanhuan'){
	$str="会员编号\t会员姓名\t转换金额\t申请类型\t转换时间t\n";
	echo $str;
	$sql="select * from zhuanhuan";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['jine']."\t";
	if($row['lx']==0){
			echo "奖金转电子币\t";
		}elseif($row['lx']==1){
			echo "奖金转购物币\t";
		}elseif($row['lx']==2){
			echo "电子币转购物币\t";
		}
		echo $row['zdate']."\t";
		
		
	}
}elseif($_GET['table']=="member"){
	$str="会员编号\t服务中心\t推荐人编号\t推荐人姓名\t接点人\t接点人姓名\t注册时间\t激活时间\t会员资格\t身份证号\t会员姓名\t联系电话\t联系地址\t详细收货地址\t开户银行\t开户账号\t开户姓名\t开户地址\t\n";
	echo $str;
	$sql="select * from member";
	$rs=mysql_query($sql);
	while($row=mysql_fetch_assoc($rs)){
		echo $row['userid']."\t";
		
		$sql2="select * from member where id={$row['bdid']}";
		$one=getOne($sql2);
		echo $one['userid']."\t";
		$sql3="select * from member where id={$row['reid']}";
		$two=getOne($sql3);
		echo $two['userid']."\t";
		echo $two['username']."\t";
		$sql4="select * from member where id={$row['fatherid']}";
		$three=getOne($sql4);
		echo $three['userid']."\t";
		echo $three['username']."\t";
		echo $row['rdt']."\t";
		echo $row['pdt']."\t";
		$sql5="select * from ulevel where ulevel={$row['ulevel']}";
		$four=getOne($sql5);
		echo $four['lvname']."\t";
		echo $row['usercard']."\t";
		echo $row['username']."\t";
		echo $row['usertel']."\t";
		echo $row['sheng'].$row['shi'].$row['xian']."\t";
		echo $row['useraddress']."\t";
		echo $row['bankname']."\t";
		echo $row['bankcard']."\t";
		echo $row['bankusername']."\t";
		echo $row['bankaddress']."\t\n";
		
	}
}elseif($_GET['table']=="week"){
	$str="会员编号\t会员姓名\t层碰奖\t量碰奖\t报单费\t区域绑定\t推荐代理奖\t重复消费\t实际发放\t\n";
	echo $str;
	$sql = "SELECT * FROM `member` as m right join (select sum(b1) as b1, sum(b2) as b2, sum(b3) as b3, sum(b4) as b4, sum(b5) as b5,sum(b6) as b6,sum(b0) as b0, uid ,bdate from bonus where date_format(bdate,'%Y-%v')='{$_GET['time']}' group by uid) as b on m.id=b.uid WHERE 1=1 ".$_SESSION['Search']." ".$_SESSION['SearchTime']."";
	$rs=getAll($sql);
	foreach($rs as $row){
		echo $row['nickname']."\t";
		echo $row['username']."\t";
		echo $row['b1']."\t";
		echo $row['b2']."\t";
		echo $row['b3']."\t";
		echo $row['b4']."\t";
		echo $row['b5']."\t";
		echo $row['b6']."\t";
		echo $row['b0']."\t\n";
	}
}elseif($_GET['table']=="bdrecord"){
    $str="报单会员编号\t报单金额\t使用报单币\t使用电子币\t报单时间\t操作人编号\t操作\t\n";
    echo $str;
    $sql = "SELECT * FROM `bdrecord`  where 1  group by id  ";
    $rs=getAll($sql);
    foreach($rs as $row){
        echo $row['nickname']."\t";
        echo $row['lsk']."\t";
        echo $row['zsq']."\t";
        echo $row['gwb']."\t";
        echo $row['bddate']."\t";
        echo $row['bdname']."\t";
        echo "已激活\t\n";
    }



}





?>